<template>
  <div>
    <h1 ref="print">
      <div class="f1">
        打印区域
        <p>1111111111111111</p>
      </div>
      <div class="no-print">
        非打印区域
        <p>22222222222</p>
      </div>
    </h1>
    <button @click="printFn">点击打印</button>
  </div>
</template>

<script>
export default {
  methods: {
    printFn() {
      this.$print(this.$refs.print); // 方法使用
    }
  }
};
</script>

<style lang="less" scoped>
div {
  text-align: center;
  padding:20px 0;
  height: 100px;
  font-size: 20px;
}
div.no-print{
}
button {
  border: none;
  background: blue;
  color: #fff;
  font-size: 18px;
}
</style>
